import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
	state: () => ({
		userInfo: uni.getStorageSync('userInfo') || {}
	}),
	
	actions: {
		// 设置用户信息
		setUserInfo(userInfo) {
			this.userInfo = userInfo;
			uni.setStorageSync('userInfo', userInfo);
		},
		
		// 清除用户信息
		clearUserInfo() {
			this.userInfo = {};
			uni.removeStorageSync('userInfo');
		},
		
		// 获取用户信息
		getUserInfo() {
			return this.userInfo;
		}
	}
}); 